package com.zy.web.controller.bs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.entity.bs.GoodsType;
import com.zy.pojo.query.bs.GoodsTypeQuery;
import com.zy.pojo.vos.common.PageVo;
import com.zy.pojo.vos.common.ResultVo;
import com.zy.service.bs.GoodsTypeService;
import com.zy.web.controller.base.BaseController;
import com.zy.web.utils.ResultUtil;

@RequestMapping("bs/goodsType")
@Controller
public class GoodsTypeController extends BaseController {

	@Autowired
	private GoodsTypeService goodsTypeService;

	/**
	 * 分页
 	 * 
 	 * @param goodsTypeQuery
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("pageGoodsType")
	@ResponseBody
	public PageVo pageGoodsType(GoodsTypeQuery goodsTypeQuery, Integer start, Integer limit) {
		return this.goodsTypeService.pageGoodsType(goodsTypeQuery, start, limit);
	}

	/**
	 * 新增
	 * 
	 * @param goodsType
	 * @return
	 */
	@RequestMapping(value = "saveGoodsType", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo saveGoodsType(GoodsType goodsType) {
		try {
			this.goodsTypeService.saveGoodsType(goodsType);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
	
	/**
	 * 更新
	 * 
	 * @param goodsType
	 * @return
	 */
	@RequestMapping(value = "updateGoodsType", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo updateGoodsType(GoodsType goodsType) {
		try {
			this.goodsTypeService.updateGoodsType(goodsType);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeGoodsType", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo removeGoodsType(long id) {
		try {
			this.goodsTypeService.removeGoodsType(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 恢复
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "recover", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo recover(long id) {
		try {
			this.goodsTypeService.recover(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

}